import java.util.Random;

public class Main {
    public static int hashCode(StringBuilder str) {
        int len = str.length();
        if (len == 0) {
            return 0;
        }
        int sum = 0;
        for (int i = 0; i < len; i++) {
            sum += str.charAt(i) * 23;
        }
        sum = Math.abs(sum);
        while (sum >= 2000) {
            sum %= 2000;
        }
        return sum;
    }

    public static StringBuilder randomString() {
        StringBuilder stringBuilder = new StringBuilder();
        Random random = new Random();

        int randomNum = random.nextInt(9) + 2;
        for (int i = 0; i < randomNum; i++) {
            stringBuilder.append((char)(random.nextInt(94) + 33));
        }
        return stringBuilder;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            System.out.println(hashCode(randomString()));
        }
    }

}
